<template>
  <div>
    <a-form :form="form" style="max-width: 500px; margin: 40px auto 0;">
      <a-radio-group @change="onChange" v-model="value">
        <a-radio class="radioStyle" :value="item.id"  :key="index"  v-for="(item,index) in dataList" >{{item.name}}({{item.standard}})</a-radio>
      </a-radio-group>
      <a-form-item :wrapperCol="{span: 19, offset: 5}">
        <a-button :loading="loading" type="primary" @click="submit">提交</a-button>
        <a-button style="margin-left: 8px" @click="prevStep">上一步</a-button>
      </a-form-item>
    </a-form>
  </div>
</template>

<script>
import { getCfeeType } from '@/api/manage'
import { mapGetters } from 'vuex'

export default {
  name: 'Step3',
  data () {
    return {
      form: this.$form.createForm(this),
      loading: false,
      dataList: [],
      value:''
    }
  },
  props : ['params'],
  created () {
    this.loading=true;
    getCfeeType({ token: this.token(), ar_id: this.pmsArId(), cm_mg_id: this.nowMg(), house_type: this.params.feeType }).then(res => {
      this.loading=false;
      if (res.code == 0) {
        this.dataList = res.data.skip
      } else {
        this.$notification['error']({
          message: '错误',
          description: res.msg,
          duration: 4
        })
      }
    })
  },
  methods: {
    ...mapGetters(['token', 'pmsArId', 'nowMg']),
    prevStep () {
      this.$emit('prevStep')
    },
    submit () {
      if(this.value){
         this.$emit('submit',this.value)
      }else{
         that.$message.error('请选择收费标准');
      }
    },
    onChange (e) {
      console.log('radio checked', e.target.value)
    },
  }
}
</script>

<style lang="less" scoped>
  .radioStyle {
    display: 'block';
    height: '30px';
    line-height: '30px';
  }

</style>
